#include "messagedisplay.h"

MessageDisplay::MessageDisplay(const QString &message, const QString &title)
{
    this->setWindowTitle(title);

    /* Set up main, label and button layout.  Qt memory management takes care
     * of memory management with the parent hierarchy when the "this" pointer
     * is used to define the parent of the topmost layout.
     */
    QVBoxLayout *mainLayout = new QVBoxLayout(this);
    QHBoxLayout *labelLayout = new QHBoxLayout;
    QHBoxLayout *buttonLayout = new QHBoxLayout;

    /* Set up the layouts so that the label is on top, and the buttons below */
    mainLayout->addLayout(labelLayout);
    mainLayout->addLayout(buttonLayout);

    /* Add the message so that is it centered in the dialog */
    labelLayout->addStretch();
    labelLayout->addWidget(new QLabel(message));
    labelLayout->addStretch();

    /* Set up the button layout so that the buttons are pushed to the right. */
    buttonLayout->addStretch();

    /* Quit button */
    QPushButton *quitButton = new QPushButton("Quit");
    connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit()));
    buttonLayout->addWidget(quitButton);

    /* Continue button */
    QPushButton *continueButton = new QPushButton("Continue");
    connect(continueButton, SIGNAL(clicked()), this, SLOT(close()));
    buttonLayout->addWidget(continueButton);
    continueButton->setDefault(true);

    /* Set the layout and size and delete orders */
    this->setAttribute(Qt::WA_DeleteOnClose);
    this->setLayout(mainLayout);
    this->resize(400, 125);

}
